import { mapMutations } from 'vuex'

export default {
  computed: {
    mainSwiperOptions() {
      let vm = this
      return {
        direction: 'vertical',
        mousewhellControl: true,
        hashnav: true,
        hashnavWatchState: true,
        on: {
          init() {
            window.swiperAnimateCache(this)
            window.swiperAnimate(this)
          },
          slideChangeTransitionStart() {
            if (this.activeIndex === this.slides.length - 1) {
              vm.setArrowBtnState(false)
            } else {
              vm.setArrowBtnState(true)
            }
          },
          slideChangeTransitionEnd() {
            window.swiperAnimate(this)
          }
        }
      }
    },
    mainSwiper() {
      return this.$refs.mainSwiper.swiper
    }
  },
  methods: {
    ...mapMutations({
      setArrowBtnState: 'SET_ARROW_BTN_STATE'
    })
  },
  created() {
    // 有swiper页面注入
    this.setArrowBtnState(true)
  }
}
